from view.endSrc.ObserverGenerator import ObserverGenerator
from view.endSrc.Observer import Observer
from view.endSrc.Dataset import Dataset
import numpy as np
import random


class SimpleObserverGenerator(ObserverGenerator):

    def __init__(self):
        ObserverGenerator.__init__(self)

    def getViewPointList(self, dataset: Dataset, nViewPoints, p2pFun, n2nFun):

        minima = np.min(dataset, axis=0)
        minima = minima - abs(minima) * 0.01
        maxima = np.max(dataset, axis=0)
        maxima = maxima + abs(maxima) * 0.01

        vpList = []

        nAttRange = range(dataset.getNumOfAttributes())
        for i in range(nViewPoints):
            record = [random.uniform(minima[j], maxima[j]) for j in nAttRange ]
            vpList.append(np.asarray(record))

        return vpList
